package org.sampleSpringFramework.mvc.render.impl;

import org.sampleSpringFramework.mvc.processor.RequestProcessorChain;
import org.sampleSpringFramework.mvc.render.ResultRender;

import javax.servlet.http.HttpServletResponse;

/**
 * 资源未找到时使用的结果渲染器
 */
public class ResourceNotFoundResultRender implements ResultRender {

	private String method;

	private String path;

	public ResourceNotFoundResultRender(String requestPath, String requestMethod) {
		this.method = requestMethod;
		this.path = requestPath;
	}

    @Override
	public void render(RequestProcessorChain requestProcessorChain) throws Exception {
		int code = HttpServletResponse.SC_NOT_FOUND;
		String msg =  "获取不到对应的请求资源：请求路径[" + path + "]" + "请求方法[" + method + "]";
		requestProcessorChain.getResponse().sendError(code,msg);
	}
}
